
#!/usr/bin/env node 
const fs=require('fs');
const log=console.log,
      join=require('path').join,
      src=process.argv[2];

if (typeof(src)==='undefined'){
  console.error('请指定要删除的名字');
  process.exit(1);
}
if(!fs.existsSync(src)){
  console.error('%s not exits!',src);
  process.exit(2);
}
if(fs.statSync(src).isFile())
  fs.unlinkSync(src);
if(fs.statSync(src).isDirectory())
  fs.deleteDir(src);
function deleteDir(folder) {
   let files = fs.readdirSync(folder);
      for(let i=0; i<files.length; i++) {
            let file = join(folder, files[i]);

            if(fs.statSync(file).isFile()) {
                    fs.unlinkSync(file);
                          continue;
                              
            }

                if(fs.statSync(file).isDirectory()) deleteDir(file);
                  
      }

        fs.rmdirSync(folder);

  }  




